<?php
namespace app\admin\model;
use think\Db;
use think\Model;

class FrCashModel extends Model
{
	 public function __construct()
	{
		parent::__construct();

	}
	public function getWithdrawList($page,$limit,$map=array(),$field='a.*'){
		return Db::table('fr_driver_withdraw a')
		->join(['fr_driver_base'=>'b'],'a.driver_uid=b.driver_uid','LEFT')
		->join(['xm_user'=>'u'],'a.driver_uid=u.uid','LEFT')
		->where($map)
		->field($field)->order('a.is_pay asc,a.id desc')->select();

	}
	public function getDriverWithdrawList($page,$limit,$map=array(),$field='a.*')
	{
		return Db::name('driver_wallet_record a')->join('__DRIVER_BANK__ b','a.driver_id = b.driver_id','LEFT')
			->join(['fr_driver_base'=>'c'],'a.driver_id = c.driver_id','LEFT')->join('__BANK__ d','b.bank_id = d.id','LEFT')
			->join('__ORDER_COMMON__ e','e.common_id = a.common_id','LEFT')
			->join('__ADMIN__ f','f.admin_id = a.auditor_id','LEFT')
			->join('__ADMIN__ g','g.admin_id = a.payer_id','LEFT')
			->page($page,$limit)->where($map)->order('a.record_id desc,a.approve desc')
			->field($field)->select();
	}

    /**
     * @param array $map
     * @param string $field
     * @param int $pay_type  提现方式 1 支付宝 2 微信 3 银行卡
     * @return array|false|\PDOStatement|string|Model
     */
	public function getDriverWithdrawInfo($map=array(),$field='a.*')
	{
//	    if($pay_type == 1) { //支付宝
//	        return Db::table('fr_driver_flow')
//                ->where($map)
//                ->order('id desc')->select();
//        } elseif($pay_type == 2) {
//	        return true;
//        } else {
            return Db::name('driver_wallet_record a')->join('__DRIVER_BANK__ b','a.driver_id = b.driver_id','LEFT')
                ->join(['fr_driver_base' => 'c'],'a.driver_id = c.driver_id','LEFT')
                ->join('__BANK__ d','b.bank_id = d.id','LEFT')
                ->where($map)->order('a.record_id desc,a.approve desc')
                ->field($field)->find();
//        }

	}


}
